package com.cgy.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cgy.entity.ConsumeLogs;
import com.cgy.repository.ConsumeLogsRepository;
import com.cgy.service.ComputerService;
import com.cgy.service.ConsumeLogsService;
import com.cgy.service.ResStatisticsService;
import com.cgy.service.StudentService;

import util.LayuiJsonUtils;

@RestController
@RequestMapping("zhuangtai")
@CrossOrigin
public class zhuangtaiController {
	//打卡
		@Autowired
		private StudentService stuService;
		@Autowired
		private ConsumeLogsService ConsumeLogsService;
		@Autowired
		private ConsumeLogsRepository cm;
		@Autowired
		private ComputerService comservice;
		//统计
		@Autowired
		private ResStatisticsService resstaservice;	
		@GetMapping("/index")
		public LayuiJsonUtils<ConsumeLogs> findAllConsumeLogs(LayuiJsonUtils<ConsumeLogs> lj,ConsumeLogs c){
			Pageable pageable = PageRequest.of(lj.getPage(), lj.getLimit());
			Page<ConsumeLogs> ConsumeLogs = ConsumeLogsService.findAllConsumeLogs(c, pageable);
			lj.setData(ConsumeLogs.getContent());
			lj.setCount(ConsumeLogs.getTotalElements());
			return lj;
		}
		//修改为上机中
		@RequestMapping("upstaticsj")
		public Integer upstatic(Integer cid) {
			
			return comservice.upcomputerstaticsj(cid);
		}
		//修改为下机
		@RequestMapping("upstaticxj")
		public Integer upstaticxj(Integer cid) {
			
			return comservice.upcomputerstaticxj(cid);
		}
	/*
	 * //修改学生状态为上机
	 * 
	 * @RequestMapping("studentsj") public Integer upStudentsj(Integer lCardId) {
	 * System.out.println(lCardId); return stuService.upstudentstatus(lCardId); }
	 */
}
